package com.example.blog.module.controller;


import com.example.blog.module.entity.VO.Result;
import com.example.blog.module.service.MessageService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zjx
 * @since 2023-04-10
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/message")
public class MessageController {

    private final MessageService messageService;

    @PostMapping("/findConversations")
    public Result findConversations(int page,int pageSize){
        return Result.success(messageService.findConversations(page,pageSize));
    }

    @PostMapping("/delConversation")
    public Result delConversation(String conservationId){
        return Result.success(messageService.delConversation(conservationId));
    }

    @PostMapping("/conversationDetail")
    public Result conversationDetail(String conservationId, int page, int pageSize){
        return Result.success(messageService.conversationDetail(conservationId,page,pageSize));
    }

    @PostMapping("/sendMessage")
    public Result sendMessage(Long toId,String content){
        return Result.success(messageService.sendMessage(toId,content));
    }

}

